package com.manli.api;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;


/**
 * 启动类
 * 继承tomcat servlet
 * @author Shensg
 *
 *
 *@EnableRedisHttpSession 启用redis管理session
 *@ServletComponentScan注解后，Servlet、Filter、Listener可以直接通过@WebServlet、@WebFilter、@WebListener注解自动注册
 *@EnableAutoConfiguration使用spring提供的配置 exclude排除datasource
 *	maxInactiveIntervalInSeconds 设置session没有活动实效时间单位秒 默认值1800 30分钟
 * 2020年3月24日
 */
@SpringBootApplication
@ServletComponentScan
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
@EnableRedisHttpSession(maxInactiveIntervalInSeconds=1800)
@Slf4j
public class ManLiStart extends SpringBootServletInitializer{
	public static void main(String[] args) {
		ApplicationContext context = SpringApplication.run(ManLiStart.class, args);
		String serverPort = context.getEnvironment().getProperty("server.port");
		String contextPath = context.getEnvironment().getProperty("server.servlet.context-path");
		log.info("Manli started at http://localhost:" + serverPort + contextPath );
	}
}
